/** @type {import('next').NextConfig} */

const { BASE_HOST_LIST } = require("./scripts/config");
const withLess = require("next-with-less");

const { SERVER_ENV = "sit" } = process.env;
const customEnvs = {
    serverEnv: SERVER_ENV,
    baseHost: BASE_HOST_LIST[SERVER_ENV] || "",
    dingtalkHost: 'https://oapi.dingtalk.com',
    gitlabHost: 'https://gitlab.jrdaimao.com',
    sonarHost: 'http://10.99.61.213:18003',
    APP_LOGIN_CHECK: "https://canarysit.jrdaimao.com",
    APP_USER_INFO: "https://canarysit.jrdaimao.com"
    // sonarHost: 'http://127.0.0.1:8082',
};

console.log('当前环境：', SERVER_ENV);

const nextConfig = {
  reactStrictMode: false,
  async rewrites() {
    return [
      {
        source: '/api_dingding/tapd',
        destination: '/api/ding/tapd'
      }
    ]
  },
  async redirects() {
    return [
      {
        source: '/',
        destination: '/dashboard',
        permanent: true,
      },
    ]
  },
  images: {
    remotePatterns: [
      {
        protocol: 'https',
        hostname: 'static-legacy.dingtalk.com',
        port: '',
        pathname: '/*/**',
      },
    ],
  },
  publicRuntimeConfig: customEnvs
}

module.exports = withLess(nextConfig);
